<div class="container-fluid">
    <div class="row-fluid">
        <div class="span3">
            <?php echo $this->partial('_menu.phtml');?>
            <!--/.well -->
        </div>
        <div class="span9">
            <div class="wrap">
                <div id="main-content">
                    <?php
                    if($this->vente['p_ventes']) $action = $this->baseUrl() .'/admin/ventes/update-ventes';
                    else $action = $this->baseUrl() .'/admin/ventes/save-ventes';
                    ?>
                    <form class="form-horizontal" name="frm" action="<?php echo $action;?>" method="post" enctype="multipart/form-data">
                        <h3>Edition</h3>
                    	<ul class="nav nav-tabs" id="edit-form-tab">
                    		<li class="frm1 active"><a href="#frm1">Généralités</a></li>
                    		<li class="frm2"><a href="#frm2">Description</a></li>
                    		<li class="frm3"><a href="#frm3">Couvertures</a></li>
                    		<li class="frm4"><a href="#frm4">Horaire</a></li>
                    		<li class="frm5"><a href="#frm5">Expo</a></li>
                    	</ul>
                    	<div class="tab-content">
                            <div id="frm1" class="tab-pane active">
                            <?php $date = new DateTime($this->vente['dtvente']); ?>
                            	<div class="control-group">
                            		<label class="control-label" for="datepicker">Date :</label>
                            		<div class="controls">
                            			<input type="text" name="nom" id="datepicker" value="<?php echo $date->format('d/m/Y'); ?>"/>
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="titre">Titre :</label>
                            		<div class="controls">
                            			<input type="text" name="titre" id="titre" value="<?php echo htmlspecialchars(stripslashes($this->vente['titre'])) ?>" placeholder="Titre" required />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="com">Commission :</label>
                            		<div class="controls">
                            			<input type="text" name="com" id="com" style="width:25px" value="<?php echo stripslashes($this->vente['com']) ?>" placeholder="Commission" />%
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label">Type de vente :</label>
                            		<div class="controls">
                            			<input type="radio" name="type_vente" value="bd" checked <?php if($this->vente['type_vente'] == "bd") { echo "checked"; } ?>/> BD &nbsp;
                            			<input type="radio" name="type_vente" value="fg" <?php if($this->vente['type_vente'] == "fg") { echo "checked"; } ?>/> FG &nbsp;
                            			<input type="radio" name="type_vente" value="obj" <?php if($this->vente['type_vente'] == "obj") { echo "checked"; } ?>/> Objets
                            		</div>
                            	</div>
                            	<?php if($this->request()->getParam('id')){ ?>
                            		<div class="control-group">
                            			<label class="control-label">Visible en ligne ?</label>
                            			<div class="controls">
                            				<input type="radio" class="radio" name="visible" value="1" <?php if($this->vente['visible']==1) echo 'checked="checked"' ?> name="visible"> Oui
                            				<input type="radio" class="radio" name="visible" value="0" <?php if($this->vente['visible']==0) echo 'checked="checked"' ?> name="visible"> Non
                            			</div>
                            		</div>
                            		<div class="control-group">
                            			<label class="control-label">Articles visibles en ligne ?</label>
                            			<div class="controls">
                            				<input class="radio" type="radio" value="1" name="articles" <?php if ($this->vente['articles_en_ligne'] == 1) { echo 'checked="checked"'; } ?>> Oui
                            				<input class="radio" type="radio" checked="checked" value="0" name="articles" <?php if ($this->vente['articles_en_ligne'] == 0) { echo 'checked="checked"'; } ?>> Non
                            			</div>
                            		</div>
                            	<?php } ?>
                            	<div class="control-group">
                            		<label class="control-label" for="rep">Répertoires des photos :</label>
                            		<div class="controls">
                            			<input type="text" name="rep" id="rep" value="<?php echo $this->vente['rep_photos'] ?>" placeholder="Répertoires des photos" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="pdf">Nom du catalogue en PDF : </label>
                            		<div class="controls">
                            			<input type="text" name="pdf" id="pdf" value="<?php echo $this->vente['catalogue'] ?>" placeholder="Nom du catalogue en PDF" />
                            		</div>
                            	</div>
                            <?php if(!$this->request()->getParam('id')) {?>
                            	<div class="control-group">
                            		<label class="control-label">Version papier dispo ?</label>
                            		<div class="controls">
                            			<input type="radio" name="cat_dispo" value="1" checked/> Oui &nbsp;
                            			<input type="radio" name="cat_dispo" value="0" /> Non
                            		</div>
                            	</div>
                            <?php }else{ ?>
                            	<div class="control-group">
                            		<label class="control-label">Catalogue papier dispo ?</label>
                            		<div class="controls">
                            			<input type="radio" name="cat_dispo" value="1" <?php if ($this->vente['cat_dispo'] == 1) { echo 'checked="checked"'; } ?>/> Oui &nbsp;
                            			<input type="radio" name="cat_dispo" value="0" <?php if ($this->vente['cat_dispo'] == 0) { echo 'checked="checked"'; } ?>/> Non
                            		</div>
                            	</div>
                            <?php } ?>
                            	<div class="control-group">
                            		<label class="control-label" for="dtlimite">Date limite ordre ?</label>
                            		<div class="controls">
                            			<input type="text" name="dtlimite" id="dtlimite" value="<?php echo stripslashes($this->vente['dtlimiteordre']) ?>" placeholder="Date limite ordre" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="msg_dispo_cat">Message si catalogue non dispo :</label>
                            		<div class="controls">
                            			<input type="text" name="msg_dispo_cat" id="msg_dispo_cat" value="<?php echo stripslashes($this->vente['msg_dispo_cat']) ?>" placeholder="Message si catalogue non dispo" />
                            		</div>
                            	</div>
                            <?php if($this->title == 'Editer' ){ ?>
                            	<div class="control-group">
                            		<label class="control-label">PDF des résultats :</label>
                            		<div class="controls">
                            			<input type="text" name="resultats" value="<?php echo $this->vente['resultats'] ?>" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label">Autoriser renumérotation ?</label>
                            		<div class="controls">
                            			<input type="radio" name="renum" value="1" <?php if ($this->vente['renum'] == 1) { echo 'checked="checked"'; } ?> /> Oui
                            			<input type="radio" name="renum" value="0" <?php if ($this->vente['renum'] == 0) { echo 'checked="checked"'; } ?> /> Non
                            		</div>
                            	</div>
                            <?php } ?>
                            </div>
                            <div id="frm2" class="tab-pane">
                            	<div>
                            	    <textarea name="contenu" cols="50" rows="15" name=""><?php echo stripslashes($this->vente['contenu']) ?></textarea>
                        			<script type="text/javascript">
                                    CKEDITOR.replace( 'contenu', {});
                                    </script>
                            	</div>
                            </div>
                            <div id="frm3" class="tab-pane">
                            	<div class="control-group">
                            		<label class="control-label">Couverture liste des ventes :</label>
                            		<div class="controls">
                            		  <?php if ($this->vente['vignette'] != "") { ?>
                                      	<a href="../../cover/$this->vente['vignette']" target="_blank" ><?php echo $this->vente['vignette']?></a><br />
                                        <p>Conserver cette vignette ? <input name="conserveVISmall" type="radio" value="1" checked /> Oui <input type="radio" name="conserveVISmall" value="<?php echo $this->vente['vignette'] ?>" /> Non</p>
                                        <p>Si vous voulez remplacer la vignette, veuillez sélectionner un nouveau fichier :</p>
                                      <?php
                                        }
                                      ?>
                            			<input type="file" name="userfileSmall" /> (petite image)
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label">Couverture détail vente :</label>
                            		<div class="controls">
                            		 <?php if ($this->vente['vignette_vente'] != "") { ?>
                                     	<a href="../../cover/$this->vente['vignette_vente']" target="_blank"><?php echo $this->vente['vignette_vente'] ?></a><br />";
                                        <p>Conserver cette vignette ? <input name="conserveVIBig" type="radio" value="1" checked /> Oui <input type="radio" name="conserveVIBig" value="<?php echo $this->vente['vignette_vente'] ?>" /> Non</p>
                                        <p>Si vous voulez remplacer la vignette, veuillez sélectionner un nouveau fichier :</p>
                               		 <?php
                                     }
                                     ?>
                            			<input type="file" name="userfileBig" />  (grande image)
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="auteur">Auteur :</label>
                            		<div class="controls">
                            			<input type="text" name="auteur" id="auteur" value="<?php echo stripslashes($this->vente['auteur']) ?>" placeholder="Auteur" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="photographe">Photographe :</label>
                            		<div class="controls">
                            			<input type="text" name="photographe" id="photographe" value="<?php echo stripslashes($this->vente['photographe']) ?>" placeholder="Photographe" />
                            		</div>
                            	</div>
                            </div>
                            <div id="frm4" class="tab-pane">
                            <?php if($this->title == 'Ajout'){ ?>
                            	<div class="control-group">
                            		<label class="control-label" for="premier">Début 1ère tranche horaire :</label>
                            		<div class="controls">
                            			<input type="text" name="premier" id="premier" placeholder="Début 1ère tranche horaire" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="second">Début 2nde tranche horaire :</label>
                            		<div class="controls">
                            			<input type="text" name="second" id="second" placeholder="Début 2nde tranche horaire" />
                            		</div>
                            	</div>
                            	<div class="control-group">
                            		<label class="control-label" for="troisieme">Début 3ème tranche horaire :</label>
                            		<div class="controls">
                            			<input type="text" name="troisieme" id="troisieme" placeholder="Début 3ème tranche horaire" />
                            		</div>
                            	</div>
                            <?php }else{
                             $ventesModel = new Admin_Model_Ventes();
                             $horaires = $ventesModel->getHoraires($this->vente['p_ventes']);
                             //print_r($horaires);
                            ?>
                            		<label class="control-label">Début 1ère tranche horaire :</label>
                            		<div class="controls">
                            		<input name="premier" type="text" value="<?php echo $this->vente['premier'] ?>" />
                            		</div>
                            		<div style="clear:both"> </div>
                            <?php foreach( $horaires as $pr) : ?>
                            		<label class="control-label"> &nbsp; </label>
                            		<div class="controls">
                            		<?php
                            		echo '<input type="checkbox" name="ckb1er[]" value="'. $pr['category_id'] .'"';
                            			$i = explode(",", $this->vente['cat_premier']);
                            			for ($compt=0; $compt<(count($i)); $compt++) {
                            				if ($pr['category_id'] == $i[$compt]) {
                            					echo " checked";
                            				}
                            			}
                            			echo "> " . sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ."<br>";
                            		?>
                            		</div>
                            		<div style="clear:both"> </div>
                            <?php endforeach ?>
                            		<label class="control-label">Début 2nde tranche horaire :</label>
                            		<div class="controls">
                            		<input name="premier" type="text" value="<?php echo $this->vente['second'] ?>" />
                            		</div>
                            		<div style="clear:both"> </div>
                            <?php foreach( $horaires as $pr) : ?>
                            		<label class="control-label"> &nbsp; </label>
                            		<div class="controls">
                            		<?php
                                    echo '<input type="checkbox" name="ckb1er[]" value="'. $pr['category_id'] .'"';
                            			$i = explode(",", $this->vente['cat_premier']);
                            			for ($compt=0; $compt<(count($i)); $compt++) {
                            				if ($pr['category_id'] == $i[$compt]) {
                            					echo " checked";
                            				}
                            			}
                            			echo "> " . sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ."<br>";
                            		?>
                            		</div>
                            		<div style="clear:both"> </div>
                            <?php endforeach ?>
                            		<label class="control-label">Début 3ème tranche horaire :</label>
                            		<div class="controls">
                            		<input name="premier" type="text" value="<?php echo $this->vente['troisieme'] ?>" />
                            		</div>
                            		<div style="clear:both"> </div>
                            <?php foreach( $horaires as $pr) : ?>
                            		<label class="control-label"> &nbsp; </label>
                            		<div class="controls">
                            		<?php
                                    echo '<input type="checkbox" name="ckb1er[]" value="'. $pr['category_id'] .'"';
                            			$i = explode(",", $this->vente['cat_premier']);
                            			for ($compt=0; $compt<(count($i)); $compt++) {
                            				if ($pr['category_id'] == $i[$compt]) {
                            					echo " checked";
                            				}
                            			}
                            			echo "> " . sprintf("%03s",$pr['min_art_num'])." -> ".sprintf("%03s",$pr['max_art_num']) . " : " . stripslashes($pr['description']) ."<br>";
                            		?>
                            		</div>
                            		<div style="clear:both"> </div>
                            <?php endforeach ?>
                            <?php } ?>
                            </div>
                            <div id="frm5" class="tab-pane">
                            	<div>
            			            <textarea name="resume" cols="50" rows="15"><?php echo stripslashes($this->vente['expo']) ?></textarea>
        			                <script type="text/javascript">
                                    CKEDITOR.replace( 'resume', {});
                                    </script>
                        		</div>
                            </div>
                        </div>
                        <div align="center" style="width:400px">
                        	<a href="<?php echo $this->baseUrl() ?>/admin/index"><input class="btn btn-primary" type="button" name="cancel" value="annulé" /></a> &nbsp;
                        	<input class="btn btn-primary" type="submit" name="submit" value="sauver" />
                            <input type="hidden" name="p_ventes" value="<?php echo $this->vente['p_ventes']; ?>">
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
    $("#datepicker").datepicker($.datepicker.regional["fr"]);
});
</script>
